this.BX=this.BX||{};this.BX.Location=this.BX.Location||{};(function(e,t,r,i){"use strict";var a=new WeakMap;var n=function(){function e(t){babelHelpers.classCallCheck(this,e);a.set(this,{writable:true,value:void 0});if(typeof t.type==="undefined"){throw new Error("Field type must be defined")}babelHelpers.classPrivateFieldSet(this,a,parseInt(t.type))}babelHelpers.createClass(e,[{key:"type",get:function e(){return babelHelpers.classPrivateFieldGet(this,a)}}]);return e}();function l(e,t){var r;if(typeof Symbol==="undefined"||e[Symbol.iterator]==null){if(Array.isArray(e)||(r=s(e))||t&&e&&typeof e.length==="number"){if(r)e=r;var i=0;var a=function e(){};return{s:a,n:function t(){if(i>=e.length)return{done:true};return{done:false,value:e[i++]}},e:function e(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n=true,l=false,o;return{s:function t(){r=e[Symbol.iterator]()},n:function e(){var t=r.next();n=t.done;return t},e:function e(t){l=true;o=t},f:function e(){try{if(!n&&r.return!=null)r.return()}finally{if(l)throw o}}}}function s(e,t){if(!e)return;if(typeof e==="string")return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor)r=e.constructor.name;if(r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(e,t)}function o(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,i=new Array(t);r<t;r++){i[r]=e[r]}return i}var u=new WeakMap;var c=function(){function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,e);u.set(this,{writable:true,value:{}});this.fields=t.fields?t.fields:[]}babelHelpers.createClass(e,[{key:"isFieldExists",value:function e(t){return typeof babelHelpers.classPrivateFieldGet(this,u)[t]!=="undefined"}},{key:"getField",value:function e(t){return this.isFieldExists(t)?babelHelpers.classPrivateFieldGet(this,u)[t]:null}},{key:"setField",value:function e(t){if(!(t instanceof n)){throw new Error("Argument field must be instance of Field!")}babelHelpers.classPrivateFieldGet(this,u)[t.type]=t;return this}},{key:"deleteField",value:function e(t){if(this.isFieldExists(t)){delete babelHelpers.classPrivateFieldGet(this,u)[t]}}},{key:"getMaxFieldType",value:function e(){var t=Object.keys(babelHelpers.classPrivateFieldGet(this,u)).sort((function(e,t){return parseInt(e)-parseInt(t)}));var r=0;if(t.length>0){r=t[t.length-1]}return r}},{key:"isEqual",value:function t(r,i){return e.areEqual(this,r,i)&&e.areEqual(r,this,i)}},{key:"fields",set:function e(t){if(!Array.isArray(t)){throw new Error("Items must be array!")}var r=l(t),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;this.setField(a)}}catch(e){r.e(e)}finally{r.f()}return this},get:function e(){return babelHelpers.classPrivateFieldGet(this,u)}}],[{key:"areEqual",value:function e(t,r,i){for(var a in t.fields){if(a>i){continue}var n=r.getField(a);if(!n){return false}if(t.fields[a].value!==n.value){return false}}return true}}]);return e}();var p=new WeakMap;var f=function(e){babelHelpers.inherits(t,e);function t(e){var r;babelHelpers.classCallCheck(this,t);r=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));p.set(babelHelpers.assertThisInitialized(r),{writable:true,value:void 0});babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(r),p,e.value||"");return r}babelHelpers.createClass(t,[{key:"value",get:function e(){return babelHelpers.classPrivateFieldGet(this,p)},set:function e(t){babelHelpers.classPrivateFieldSet(this,p,t);return this}}]);return t}(n);var d=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}babelHelpers.createClass(t,[{key:"getFieldValue",value:function e(t){var r=null;if(this.isFieldExists(t)){var i=this.getField(t);if(i){r=i.value}}return r}},{key:"setFieldValue",value:function e(t,r){this.setField(new f({type:t,value:r}));return this}}]);return t}(c);var b=new WeakMap;var v=new WeakMap;var h=function(){function e(t){babelHelpers.classCallCheck(this,e);b.set(this,{writable:true,value:void 0});v.set(this,{writable:true,value:void 0});babelHelpers.classPrivateFieldSet(this,b,t.entityId);babelHelpers.classPrivateFieldSet(this,v,t.entityType)}babelHelpers.createClass(e,[{key:"entityId",get:function e(){return babelHelpers.classPrivateFieldGet(this,b)}},{key:"entityType",get:function e(){return babelHelpers.classPrivateFieldGet(this,v)}}]);return e}();function y(e,t){var r;if(typeof Symbol==="undefined"||e[Symbol.iterator]==null){if(Array.isArray(e)||(r=g(e))||t&&e&&typeof e.length==="number"){if(r)e=r;var i=0;var a=function e(){};return{s:a,n:function t(){if(i>=e.length)return{done:true};return{done:false,value:e[i++]}},e:function e(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n=true,l=false,s;return{s:function t(){r=e[Symbol.iterator]()},n:function e(){var t=r.next();n=t.done;return t},e:function e(t){l=true;s=t},f:function e(){try{if(!n&&r.return!=null)r.return()}finally{if(l)throw s}}}}function g(e,t){if(!e)return;if(typeof e==="string")return E(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor)r=e.constructor.name;if(r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return E(e,t)}function E(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,i=new Array(t);r<t;r++){i[r]=e[r]}return i}var H=new WeakMap;var P=function(){function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,e);H.set(this,{writable:true,value:[]});this.links=!!t.links?t.links:[]}babelHelpers.createClass(e,[{key:"addLink",value:function e(t){if(!(t instanceof h)){throw new Error("Argument link must be instance of Field!")}babelHelpers.classPrivateFieldGet(this,H).push(t)}},{key:"clearLinks",value:function e(){babelHelpers.classPrivateFieldSet(this,H,[])}},{key:"links",set:function e(t){if(!Array.isArray(t)){throw new Error("links must be array!")}var r=y(t),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;this.addLink(a)}}catch(e){r.e(e)}finally{r.f()}},get:function e(){return babelHelpers.classPrivateFieldGet(this,H)}}]);return e}();var T=new WeakMap;var k=new WeakMap;var w=new WeakMap;var C=function(e){babelHelpers.inherits(t,e);function t(e){var r;babelHelpers.classCallCheck(this,t);r=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));T.set(babelHelpers.assertThisInitialized(r),{writable:true,value:void 0});k.set(babelHelpers.assertThisInitialized(r),{writable:true,value:void 0});w.set(babelHelpers.assertThisInitialized(r),{writable:true,value:void 0});babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(r),T,parseInt(e.sort));babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(r),k,e.name||"");babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(r),w,e.description||"");return r}babelHelpers.createClass(t,[{key:"sort",get:function e(){return babelHelpers.classPrivateFieldGet(this,T)},set:function e(t){babelHelpers.classPrivateFieldSet(this,T,t)}},{key:"name",get:function e(){return babelHelpers.classPrivateFieldGet(this,k)},set:function e(t){babelHelpers.classPrivateFieldSet(this,k,t)}},{key:"description",get:function e(){return babelHelpers.classPrivateFieldGet(this,w)},set:function e(t){babelHelpers.classPrivateFieldSet(this,w,t)}}]);return t}(n);var m=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}babelHelpers.createClass(t,[{key:"initFields",value:function e(t){var r=this;if(Array.isArray(t)){t.forEach((function(e){var t=new C(e);if(t){r.setField(t)}}))}}}]);return t}(c);var F=function e(){babelHelpers.classCallCheck(this,e)};babelHelpers.defineProperty(F,"UNKNOWN",0);babelHelpers.defineProperty(F,"COUNTRY",100);babelHelpers.defineProperty(F,"ADM_LEVEL_1",200);babelHelpers.defineProperty(F,"ADM_LEVEL_2",210);babelHelpers.defineProperty(F,"ADM_LEVEL_3",220);babelHelpers.defineProperty(F,"ADM_LEVEL_4",230);babelHelpers.defineProperty(F,"LOCALITY",300);babelHelpers.defineProperty(F,"SUB_LOCALITY",310);babelHelpers.defineProperty(F,"SUB_LOCALITY_LEVEL_1",320);babelHelpers.defineProperty(F,"SUB_LOCALITY_LEVEL_2",330);babelHelpers.defineProperty(F,"STREET",340);babelHelpers.defineProperty(F,"BUILDING",400);babelHelpers.defineProperty(F,"ADDRESS_LINE_1",410);babelHelpers.defineProperty(F,"FLOOR",420);babelHelpers.defineProperty(F,"ROOM",430);babelHelpers.defineProperty(F,"TMP_TYPE_HINT",5010);babelHelpers.defineProperty(F,"TMP_TYPE_CLARIFICATION",5020);var S=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(F);babelHelpers.defineProperty(S,"POSTAL_CODE",50);babelHelpers.defineProperty(S,"ADDRESS_LINE_2",600);babelHelpers.defineProperty(S,"RECIPIENT_COMPANY",700);babelHelpers.defineProperty(S,"RECIPIENT",710);babelHelpers.defineProperty(S,"PO_BOX",800);var A=function e(t,r){babelHelpers.classCallCheck(this,e);this.type=t;this.template=r};var _=new WeakMap;var I=function(){function e(t){babelHelpers.classCallCheck(this,e);_.set(this,{writable:true,value:{}});for(var r in t){if(t.hasOwnProperty(r)){this.setTemplate(new A(r,t[r]))}}}babelHelpers.createClass(e,[{key:"isTemplateExists",value:function e(t){return typeof babelHelpers.classPrivateFieldGet(this,_)[t]!=="undefined"}},{key:"getTemplate",value:function e(t){return this.isTemplateExists(t)?babelHelpers.classPrivateFieldGet(this,_)[t]:null}},{key:"setTemplate",value:function e(t){if(!(t instanceof A)){throw new Error("Argument template must be instance of FormatTemplate!")}babelHelpers.classPrivateFieldGet(this,_)[t.type]=t}}]);return e}();var R=function e(){babelHelpers.classCallCheck(this,e)};babelHelpers.defineProperty(R,"DEFAULT","DEFAULT");babelHelpers.defineProperty(R,"AUTOCOMPLETE","AUTOCOMPLETE");babelHelpers.defineProperty(R,"ADDRESS_LINE_1","ADDRESS_LINE_1");var L=function(){function e(r){babelHelpers.classCallCheck(this,e);if(t.Type.isUndefined(r.languageId)){throw new TypeError("LanguageId must be defined")}this.languageId=r.languageId;this.code=r.code||"";this.name=r.name||"";this.templateAutocomplete=r.templateAutocomplete||"";this.templateAddressLine1=r.templateAddressLine1||"";this.description=r.description||"";this.delimiter=r.delimiter||", ";this.fieldForUnRecognized=r.fieldForUnRecognized||S.UNKNOWN;this.fieldCollection=new m;if(t.Type.isObject(r.fieldCollection)){this.fieldCollection.initFields(r.fieldCollection)}var i={};if(t.Type.isObject(r.templateCollection)){i=r.templateCollection}this.templateCollection=new I(i)}babelHelpers.createClass(e,[{key:"getField",value:function e(t){return this.fieldCollection.getField(t)}},{key:"isFieldExists",value:function e(t){return this.fieldCollection.isFieldExists(t)}},{key:"getTemplate",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:R.DEFAULT;return this.templateCollection.getTemplate(t)}},{key:"isTemplateExists",value:function e(t){return this.templateCollection.isTemplateExists(t)}},{key:"template",get:function e(){return this.templateCollection.getTemplate()}}]);return e}();function x(e,t,r){if(!t.has(e)){throw new TypeError("attempted to get private field on non-instance")}return r}var M="#S#";var O="\\s*,\\s*";var G='(\\"([^"\\\\]*|\\\\"|\\\\\\\\|\\\\)*")';var N=G;var B="([a-zA-Z][a-zA-Z_0-9]*(:(NU|UN|N|U))?)";var D="\\s*\\]";var W=D;var Y="\\s*,\\s*\\[\\s*";var j='(([^\\[\\\\]|\\\\\\[|\\\\\\\\)*)(\\[\\s*)("([^"\\\\]*|\\\\"|\\\\\\\\|\\\\)*")\\s*,\\s*\\[\\s*';var U=1100;var J=1110;var V=1120;var X=1130;var z=1140;var q=1150;var $=1160;var K=1170;var Z=1180;var Q=1190;var ee=1200;var te=1210;var re=new WeakMap;var ie=new WeakMap;var ae=new WeakMap;var ne=new WeakMap;var le=new WeakSet;var se=new WeakSet;var oe=new WeakSet;var ue=function(){function e(t,r,i){var a=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;babelHelpers.classCallCheck(this,e);oe.add(this);se.add(this);le.add(this);re.set(this,{writable:true,value:""});ie.set(this,{writable:true,value:""});ae.set(this,{writable:true,value:false});ne.set(this,{writable:true,value:null});babelHelpers.classPrivateFieldSet(this,re,t);babelHelpers.classPrivateFieldSet(this,ie,r);babelHelpers.classPrivateFieldSet(this,ae,i);babelHelpers.classPrivateFieldSet(this,ne,a)}babelHelpers.createClass(e,[{key:"getErrorCodes",value:function e(){var t={};t[U]="ERR_PARSE_GROUP_START_POSITION";t[J]="ERR_PARSE_GROUP_START";t[V]="ERR_PARSE_GROUP_DELIMITER";t[X]="ERR_PARSE_PART_FROM_DELIMITER_TO_FIELD_LIST";t[z]="ERR_PARSE_GROUP_FIELD_TEXT";t[q]="ERR_PARSE_GROUP_FIELD_NAME";t[$]="ERR_PARSE_GROUP_FIELD";t[K]="ERR_PARSE_GROUP_FIELD_LIST";t[Z]="ERR_PARSE_GROUP_FIELD_LIST_DELIMITER";t[Q]="ERR_PARSE_GROUP_FIELD_LIST_END";t[ee]="ERR_PARSE_GROUP_END";t[te]="ERR_PARSE_GROUP";return t}},{key:"getErrorsText",value:function e(r){var i="";var a=this.getErrorCodes();var n=r["error"]["errors"];for(var l=0;l<n.length;l++){i+="Error: ".concat(n[l]["position"],", ").concat(a[n[l]["code"]],"\n");if(n[l].hasOwnProperty("info")&&t.Type.isPlainObject(n[l]["info"])){var s=n[l]["info"];var o=true;for(var u in s){if(s.hasOwnProperty(u)){var c=s[u];var p=false;if(t.Type.isString(c)){c='"'.concat(c,'"');p=true}else if(t.Type.isNumber(c)||t.Type.isFloat(c)){p=true}else if(t.Type.isBoolean(c)){c=c?"true":"false";p=true}else if(t.Type.isArray(c)){c="[...]";p=true}else if(t.Type.isObject(c)){c="{...}";p=true}if(p){if(o){i+="  Error info:\n";o=false}i+="    ".concat(u,": ").concat(c,"\n")}}}}}var f=r["template"].replace("\n","\\n");f=f.replace('"','\\"');i+='Template: "'.concat(f,'"\n\n');return i}},{key:"createContext",value:function e(){return{level:0,position:0,template:"",address:null,info:{},hasError:false,error:{code:0,position:0,errors:[],info:{}}}}},{key:"clearContextInfo",value:function e(t){t["info"]={};return t}},{key:"clearContextError",value:function e(t){t["hasError"]=false;t["error"]={code:0,position:0,errors:[],info:{}};return t}},{key:"clearContextInfoAndError",value:function e(t){return this.clearContextError(this.clearContextInfo(t))}},{key:"unescapeText",value:function e(t){var r="";var i;for(i=0;i<t.length;i++){if(t[i]==="\\"){if(t.length-i>1){r+=t[++i]}}else{r+=t[i]}}return r}},{key:"parseGroupDelimiter",value:function e(t){var r=t["position"];var i=new RegExp(G,"mg");i.lastIndex=r;var a=i.exec(t["template"]);if(a&&a.index===r){t["info"]={position:r,end:r+a[0].length,value:this.unescapeText(t["template"].substr(r+1,a[0].length-2))};t["position"]=t["info"]["end"]}else{this.addContextError(t,V,r)}return t}},{key:"parseFieldText",value:function e(t){var r=t["position"];var i=new RegExp(N,"mg");i.lastIndex=r;var a=i.exec(t["template"]);if(a&&a.index===r){t["info"]={type:"text",position:r,end:r+a[0].length,value:this.unescapeText(t["template"].substr(r+1,a[0].length-2))};t["position"]=t["info"]["end"]}else{this.addContextError(t,z,r)}return t}},{key:"splitFieldName",value:function e(t){var r=t.split(":");var i=r[0];var a=r.length>1?r[1]:"";return[i,a]}},{key:"getAddressFieldValue",value:function e(r,i,a){var n="";if(!t.Type.isUndefined(S[i])){if(i==="ADM_LEVEL_1"||i==="ADM_LEVEL_2"){n=x(this,oe,fe).call(this,r,S[i])}else{n=r.getFieldValue(S[i])}if(n===null){n=x(this,se,pe).call(this,i,r)}}if(!t.Type.isString(n)){n=""}if(n!==""){if(a.indexOf("N")>=0){n=n.replace(/(\r\n|\n|\r)/g,"#S#")}if(a.indexOf("U")>=0){n=n.toUpperCase()}}return n}},{key:"parseFieldName",value:function e(t){var r=t["position"];var i=new RegExp(B,"mg");i.lastIndex=r;var a=i.exec(t["template"]);if(a&&a.index===r){t["position"]=r+a[0].length;var n=this.splitFieldName(a[0]);var l=n[0];var s=n[1];var o=this.getAddressFieldValue(t["address"],l,s);t["info"]={type:"field",position:r,end:t["position"],modifiers:s,name:l,value:o}}else{this.addContextError(t,q,r)}return t}},{key:"parseFieldListDelimiter",value:function e(t){var r=t["position"];var i=new RegExp(O,"mg");i.lastIndex=r;var a=i.exec(t["template"]);if(a&&a.index===r){t["position"]=r+a[0].length}else{this.addContextError(t,Z,r)}return t}},{key:"parseFieldListEnd",value:function e(t){var r=t["position"];var i=new RegExp(D,"mg");i.lastIndex=r;var a=i.exec(t["template"]);if(a&&a.index===r){t["position"]=r+a[0].length}else{this.addContextError(t,Q,r)}return t}},{key:"parseField",value:function e(t){var r=[];var i=t["position"];var a=[];t=this.parseFieldText(t);if(t["hasError"]){this.unshiftError(a,t["error"]["code"],t["error"]["position"]);t=this.clearContextInfoAndError(t);t=this.parseFieldName(t)}if(t["hasError"]){this.unshiftError(a,t["error"]["code"],t["error"]["position"]);t=this.clearContextInfoAndError(t);t=this.parseGroup(t);if(t["hasError"]){this.unshiftError(a,t["error"]["code"],t["error"]["position"])}else if(t["info"]["position"]>i){this.addContextError(t,U,i);this.unshiftError(a,t["error"]["code"],t["error"]["position"])}}if(!t["hasError"]){r=t["info"];r["isFieldListEnd"]=false;t=this.clearContextInfo(t);t=this.parseFieldListDelimiter(t);if(t["hasError"]){this.unshiftError(a,t["error"]["code"],t["error"]["position"]);t=this.clearContextInfoAndError(t);t=this.parseFieldListEnd(t);if(t["hasError"]){this.unshiftError(a,t["error"]["code"],t["error"]["position"])}else{r["isFieldListEnd"]=true}}}if(t["hasError"]){this.unshiftError(a,$,i);this.addContextErrors(t,a)}else{t["info"]=r}return t}},{key:"parseGroupFieldList",value:function e(t){var r=t["position"];var i=[];var a=new RegExp(Y,"mg");a.lastIndex=r;var n=a.exec(t["template"]);if(n&&n.index===r){t["position"]=r+n[0].length;var l=false;while(!(t["hasError"]||l)){t=this.parseField(t);if(!t["hasError"]){l=t["info"].hasOwnProperty("isFieldListEnd")&&t["info"]["isFieldListEnd"];if(t["info"]["value"]!==""){i.push(t["info"]["value"])}t=this.clearContextInfo(t)}}if(!t["hasError"]){t["info"]={fieldValues:i}}}else{this.addContextError(t,X,r)}if(t["hasError"]){this.addContextError(t,K,r)}return t}},{key:"parseGroupStart",value:function e(t){var r=new RegExp(j,"mg");r.lastIndex=t["position"];var i=r.exec(t["template"]);if(i){t["info"]["groupStartPosition"]=i.index+i[1].length;t["info"]["groupDelimiterStartPosition"]=i.index+i[1].length+i[3].length}else{this.addContextError(t,J,t["position"])}return t}},{key:"parseGroupEnd",value:function e(t){var r=t["position"];var i=new RegExp(W,"mg");i.lastIndex=r;var a=i.exec(t["template"]);if(a&&a.index===r){t["position"]=r+a[0].length}else{this.addContextError(t,ee,r)}return t}},{key:"parseGroup",value:function e(t){var r=t["position"];var i=0;var a="";var n=[];t["level"]++;t=this.parseGroupStart(t);if(!t["hasError"]){i=t["info"]["groupStartPosition"];t["position"]=t["info"]["groupDelimiterStartPosition"];t=this.clearContextInfo(t);t=this.parseGroupDelimiter(t)}if(!t["hasError"]){a=t["info"]["value"];t=this.clearContextInfo(t);t=this.parseGroupFieldList(t)}if(!t["hasError"]){n=t["info"]["fieldValues"];t=this.clearContextInfo(t);t=this.parseGroupEnd(t)}if(!t["hasError"]){n=babelHelpers.toConsumableArray(new Set(n));var l=n.join(a);var s=new RegExp("(".concat(a,"){2,}"),"gim");l=l.replace(new RegExp(s),a);t["info"]={type:"group",position:i,end:t["position"],value:l}}t["level"]--;if(t["hasError"]){this.addContextError(t,te,r,{groupStartPosition:i})}return t}},{key:"appendTextBlock",value:function e(t,r,i){var a=t.length-1;var n=a>=0?t[a]:null;if(n&&n.hasOwnProperty("type")&&n["type"]==="text"){t[a]["value"]+=i;t[a]["length"]+=i.length}else{t[++a]={type:"text",position:r,length:i.length,value:i}}}},{key:"appendGroupBlock",value:function e(t,r,i){t.push({type:"group",position:r,length:i.length,value:i})}},{key:"unshiftError",value:function e(r,i,a){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;r.unshift({code:i,position:a,info:t.Type.isPlainObject(n)?n:{}})}},{key:"addContextError",value:function e(r,i,a){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;r["hasError"]=true;r["error"]["code"]=i;r["error"]["position"]=a;r["error"]["info"]=t.Type.isPlainObject(n)?n:{};this.unshiftError(r["error"]["errors"],i,a,n)}},{key:"addContextErrors",value:function e(r,i){var a=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;r["hasError"]=true;r["error"]["code"]=i[0]["code"];r["error"]["position"]=i[0]["position"];r["error"]["info"]=t.Type.isPlainObject(a)?a:{};r["error"]["errors"].splice(0,0,i)}},{key:"parseBlocks",value:function e(r){var i=[];var a=r["template"].length;while(r["position"]<a){var n=r["position"];r=this.parseGroup(r);if(r["hasError"]){var l=r["error"]["info"];var s=void 0;if(!t.Type.isPlainObject(l)&&l.hasOwnProperty("groupStartPosition")&&l["groupStartPosition"]>n){s=l["groupStartPosition"]-n+1}else{s=1}this.appendTextBlock(i,r["error"]["position"],r["template"].substr(n,s));r=this.clearContextInfoAndError(r);r["position"]=n+s}else{var o=r["info"]["position"];if(o>n){this.appendTextBlock(i,n,r["template"].substr(n,o-n))}if(r["info"]["value"]!==""){this.appendGroupBlock(i,o,r["info"]["value"])}r=this.clearContextInfo(r)}}if(!r["hasError"]){r["info"]={blocks:i}}return r}},{key:"convert",value:function e(r){var i="";var a=this.createContext();a["template"]=babelHelpers.classPrivateFieldGet(this,re);a["address"]=r;a=this.parseBlocks(a);if(!a["hasError"]){var n=a["info"]["blocks"];for(var l=0;l<n.length;l++){if(n[l]["type"]==="text"){i+=this.unescapeText(n[l]["value"])}else{i+=n[l]["value"]}}}if(i!==""){var s=i.split(M);var o=[];for(var u=0;u<s.length;u++){if(s[u]!==""){o.push(s[u])}}if(babelHelpers.classPrivateFieldGet(this,ae)&&o.length>0){for(var c=0;c<o.length;c++){o[c]=t.Text.encode(o[c])}}i=o.join(babelHelpers.classPrivateFieldGet(this,ie))}return i}}]);return e}();var ce=function e(t){return babelHelpers.classPrivateFieldGet(this,ne)&&babelHelpers.classPrivateFieldGet(this,ne).getTemplate(t)!==null};var pe=function e(t,r){if(!x(this,le,ce).call(this,t)){return null}var i=babelHelpers.classPrivateFieldGet(this,ne).getTemplate(t).template;var a=new ue(i,babelHelpers.classPrivateFieldGet(this,ie),babelHelpers.classPrivateFieldGet(this,ae),babelHelpers.classPrivateFieldGet(this,ne));return a.convert(r)};var fe=function e(r,i){var a=r.getFieldValue(S.LOCALITY);a=t.Type.isString(a)?a:"";var n=r.getFieldValue(i);if(!t.Type.isString(n)){n=""}if(n!==""&&a!==""){var l=a.toUpperCase();var s=n.toUpperCase();if(s.length>=l.length){var o=s.substr(s.length-l.length);if(l===o){n=""}}}return n};var de=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"convertAddressToString",value:function t(r,i,a,n){var l;if(a===e.STRATEGY_TYPE_TEMPLATE||a===e.STRATEGY_TYPE_TEMPLATE_COMMA||a===e.STRATEGY_TYPE_TEMPLATE_NL||a===e.STRATEGY_TYPE_TEMPLATE_BR){var s=null;switch(a){case e.STRATEGY_TYPE_TEMPLATE_COMMA:s=", ";break;case e.STRATEGY_TYPE_TEMPLATE_NL:s="\n";break;case e.STRATEGY_TYPE_TEMPLATE_BR:s="<br />";break}l=e.convertAddressToStringTemplate(r,i.getTemplate(),n,s,i)}else if(a===e.STRATEGY_TYPE_FIELD_SORT){var o=function e(t,r){return t.sort-r.sort};l=e.convertAddressToStringByField(r,i,o,n)}else if(a===e.STRATEGY_TYPE_FIELD_TYPE){var u=function e(t,r){var i;if(t.type===0){i=1}else if(r.type===0){i=-1}else{i=t.type-r.type}return i};l=e.convertAddressToStringByField(r,i,u,n)}else{throw TypeError("Wrong strategyType")}return l}},{key:"convertAddressToStringTemplate",value:function t(r,i,a){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var l=arguments.length>4&&arguments[4]!==undefined?arguments[4]:null;var s=a===e.CONTENT_TYPE_HTML;if(n===null){n=s?"<br />":"\n"}var o=new ue(i.template,n,s,l);return o.convert(r)}},{key:"convertAddressToStringByField",value:function r(i,a,n,l){if(!(a instanceof L)){BX.debug("format must be instance of Format")}if(!(i instanceof Se)){BX.debug("address must be instance of Address")}var s=a.fieldCollection;if(!s){return""}var o=Object.values(s.fields);o.sort(n);var u="";for(var c=0,p=o;c<p.length;c++){var f=p[c];var d=i.getFieldValue(f.type);if(d===null){continue}if(l===e.CONTENT_TYPE_HTML){d=t.Text.encode(d)}if(u!==""){u+=a.delimiter}u+=d}return u}}]);return e}();babelHelpers.defineProperty(de,"STRATEGY_TYPE_TEMPLATE","template");babelHelpers.defineProperty(de,"STRATEGY_TYPE_TEMPLATE_COMMA","template_comma");babelHelpers.defineProperty(de,"STRATEGY_TYPE_TEMPLATE_NL","template_nl");babelHelpers.defineProperty(de,"STRATEGY_TYPE_TEMPLATE_BR","template_br");babelHelpers.defineProperty(de,"STRATEGY_TYPE_FIELD_SORT","field_sort");babelHelpers.defineProperty(de,"STRATEGY_TYPE_FIELD_TYPE","field_type");babelHelpers.defineProperty(de,"CONTENT_TYPE_HTML","html");babelHelpers.defineProperty(de,"CONTENT_TYPE_TEXT","text");function be(e,t,r){if(e!==t){throw new TypeError("Private static access of wrong provenance")}return r}var ve=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"convertJsonToAddress",value:function e(t){return new Se(t)}},{key:"convertAddressToJson",value:function t(r){var i={id:r.id,languageId:r.languageId,latitude:r.latitude,longitude:r.longitude,fieldCollection:be(e,e,ye).call(e,r.fieldCollection),links:be(e,e,he).call(e,r.links),location:null};if(r.location){i.location=JSON.parse(r.location.toJson())}return JSON.stringify(i)}}]);return e}();var he=function e(t){return t.map((function(e){return{entityId:e.entityId,entityType:e.entityType}}))};var ye=function e(t){var r={};Object.values(t.fields).forEach((function(e){r[e.type]=e.value}));return r};function ge(e,t){var r;if(typeof Symbol==="undefined"||e[Symbol.iterator]==null){if(Array.isArray(e)||(r=Ee(e))||t&&e&&typeof e.length==="number"){if(r)e=r;var i=0;var a=function e(){};return{s:a,n:function t(){if(i>=e.length)return{done:true};return{done:false,value:e[i++]}},e:function e(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n=true,l=false,s;return{s:function t(){r=e[Symbol.iterator]()},n:function e(){var t=r.next();n=t.done;return t},e:function e(t){l=true;s=t},f:function e(){try{if(!n&&r.return!=null)r.return()}finally{if(l)throw s}}}}function Ee(e,t){if(!e)return;if(typeof e==="string")return He(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor)r=e.constructor.name;if(r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return He(e,t)}function He(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,i=new Array(t);r<t;r++){i[r]=e[r]}return i}var Pe=new WeakMap;var Te=new WeakMap;var ke=new WeakMap;var we=new WeakMap;var Ce=new WeakMap;var me=new WeakMap;var Fe=new WeakMap;var Se=function(){function e(r){babelHelpers.classCallCheck(this,e);Pe.set(this,{writable:true,value:void 0});Te.set(this,{writable:true,value:void 0});ke.set(this,{writable:true,value:void 0});we.set(this,{writable:true,value:void 0});Ce.set(this,{writable:true,value:void 0});me.set(this,{writable:true,value:void 0});Fe.set(this,{writable:true,value:void 0});if(t.Type.isUndefined(r.languageId)){throw new TypeError("languageId must be defined")}babelHelpers.classPrivateFieldSet(this,Te,r.languageId);babelHelpers.classPrivateFieldSet(this,Pe,r.id||0);babelHelpers.classPrivateFieldSet(this,ke,r.latitude||"");babelHelpers.classPrivateFieldSet(this,we,r.longitude||"");babelHelpers.classPrivateFieldSet(this,Ce,new d);if(t.Type.isObject(r.fieldCollection)){for(var i=0,a=Object.entries(r.fieldCollection);i<a.length;i++){var n=babelHelpers.slicedToArray(a[i],2),l=n[0],s=n[1];this.setFieldValue(l,s)}}babelHelpers.classPrivateFieldSet(this,me,new P);if(t.Type.isArray(r.links)){var o=ge(r.links),u;try{for(o.s();!(u=o.n()).done;){var c=u.value;this.addLink(c.entityId,c.entityType)}}catch(e){o.e(e)}finally{o.f()}}babelHelpers.classPrivateFieldSet(this,Fe,null);if(r.location){if(r.location instanceof Xe){babelHelpers.classPrivateFieldSet(this,Fe,r.location)}else if(t.Type.isObject(r.location)){babelHelpers.classPrivateFieldSet(this,Fe,new Xe(r.location))}else{BX.debug("Wrong typeof props.location")}}}babelHelpers.createClass(e,[{key:"setFieldValue",value:function e(t,r){babelHelpers.classPrivateFieldGet(this,Ce).setFieldValue(t,r)}},{key:"getFieldValue",value:function e(t){return babelHelpers.classPrivateFieldGet(this,Ce).getFieldValue(t)}},{key:"isFieldExists",value:function e(t){return babelHelpers.classPrivateFieldGet(this,Ce).isFieldExists(t)}},{key:"toJson",value:function e(){return ve.convertAddressToJson(this)}},{key:"toString",value:function e(t,r,i){if(!(t instanceof L)){console.error("format must be instance of Format");return""}var a=r||de.STRATEGY_TYPE_TEMPLATE;var n=i||de.CONTENT_TYPE_HTML;return de.convertAddressToString(this,t,a,n)}},{key:"toLocation",value:function e(){var t=null;if(this.location){var r=JSON.parse(this.location.toJson());r.address=JSON.parse(this.toJson());t=new Xe(r)}return t}},{key:"getType",value:function e(){return babelHelpers.classPrivateFieldGet(this,Ce).getMaxFieldType()}},{key:"addLink",value:function e(t,r){babelHelpers.classPrivateFieldGet(this,me).addLink(new h({entityId:t,entityType:r}))}},{key:"clearLinks",value:function e(){babelHelpers.classPrivateFieldGet(this,me).clearLinks()}},{key:"id",get:function e(){return babelHelpers.classPrivateFieldGet(this,Pe)},set:function e(t){babelHelpers.classPrivateFieldSet(this,Pe,t)}},{key:"location",get:function e(){return babelHelpers.classPrivateFieldGet(this,Fe)},set:function e(t){babelHelpers.classPrivateFieldSet(this,Fe,t)}},{key:"languageId",get:function e(){return babelHelpers.classPrivateFieldGet(this,Te)}},{key:"fieldCollection",get:function e(){return babelHelpers.classPrivateFieldGet(this,Ce)}},{key:"latitude",get:function e(){return babelHelpers.classPrivateFieldGet(this,ke)},set:function e(t){babelHelpers.classPrivateFieldSet(this,ke,t)}},{key:"longitude",get:function e(){return babelHelpers.classPrivateFieldGet(this,we)},set:function e(t){babelHelpers.classPrivateFieldSet(this,we,t)}},{key:"links",get:function e(){return babelHelpers.classPrivateFieldGet(this,me).links}}]);return e}();var Ae=new WeakMap;var _e=function(e){babelHelpers.inherits(t,e);function t(e){var r;babelHelpers.classCallCheck(this,t);r=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));Ae.set(babelHelpers.assertThisInitialized(r),{writable:true,value:void 0});babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(r),Ae,e.value||"");return r}babelHelpers.createClass(t,[{key:"value",get:function e(){return babelHelpers.classPrivateFieldGet(this,Ae)},set:function e(t){babelHelpers.classPrivateFieldSet(this,Ae,t)}}]);return t}(n);var Ie=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}babelHelpers.createClass(t,[{key:"getFieldValue",value:function e(t){var r=null;if(this.isFieldExists(t)){var i=this.getField(t);if(i){r=i.value}}return r}},{key:"setFieldValue",value:function e(t,r){this.setField(new _e({type:t,value:r}));return this}}]);return t}(c);function Re(e,t,r){if(e!==t){throw new TypeError("Private static access of wrong provenance")}return r}var Le=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"convertLocationToObject",value:function t(r){if(!(r instanceof Xe)){throw new TypeError("location must be type of location")}var i={id:r.id,code:r.code,externalId:r.externalId,sourceCode:r.sourceCode,type:r.type,name:r.name,languageId:r.languageId,latitude:r.latitude,longitude:r.longitude,fieldCollection:Re(e,e,xe).call(e,r.fieldCollection),address:null};if(r.address){i.address=JSON.parse(r.address.toJson())}return i}}]);return e}();var xe=function e(t){var r={};Object.values(t.fields).forEach((function(e){r[e.type]=e.value}));return r};var Me=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"convertJsonToLocation",value:function e(t){var r=babelHelpers.objectSpread({},t);if(t.address){r.address=new Se(t.address)}return new Xe(r)}},{key:"convertLocationToJson",value:function e(t){if(!(t instanceof Xe)){throw new TypeError("location must be type of location")}var r=Le.convertLocationToObject(t);return r?JSON.stringify(r):""}}]);return e}();var Oe=new WeakMap;var Ge=new WeakMap;var Ne=new WeakMap;var Be=new WeakMap;var De=new WeakMap;var We=new WeakMap;var Ye=new WeakMap;var je=new WeakMap;var Ue=new WeakMap;var Je=new WeakMap;var Ve=new WeakMap;var Xe=function(){function e(){var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,e);Oe.set(this,{writable:true,value:void 0});Ge.set(this,{writable:true,value:void 0});Ne.set(this,{writable:true,value:void 0});Be.set(this,{writable:true,value:void 0});De.set(this,{writable:true,value:void 0});We.set(this,{writable:true,value:void 0});Ye.set(this,{writable:true,value:void 0});je.set(this,{writable:true,value:void 0});Ue.set(this,{writable:true,value:void 0});Je.set(this,{writable:true,value:void 0});Ve.set(this,{writable:true,value:void 0});babelHelpers.classPrivateFieldSet(this,Oe,parseInt(r.id)||0);babelHelpers.classPrivateFieldSet(this,Ge,r.code||"");babelHelpers.classPrivateFieldSet(this,Ne,r.externalId||"");babelHelpers.classPrivateFieldSet(this,Be,r.sourceCode||"");babelHelpers.classPrivateFieldSet(this,De,parseInt(r.type)||0);babelHelpers.classPrivateFieldSet(this,We,r.name||"");babelHelpers.classPrivateFieldSet(this,Ye,r.languageId||"");babelHelpers.classPrivateFieldSet(this,je,r.latitude||"");babelHelpers.classPrivateFieldSet(this,Ue,r.longitude||"");babelHelpers.classPrivateFieldSet(this,Ve,new Ie);if(t.Type.isObject(r.fieldCollection)){for(var i=0,a=Object.entries(r.fieldCollection);i<a.length;i++){var n=babelHelpers.slicedToArray(a[i],2),l=n[0],s=n[1];this.setFieldValue(l,s)}}babelHelpers.classPrivateFieldSet(this,Je,null);if(r.address){if(r.address instanceof Se){babelHelpers.classPrivateFieldSet(this,Je,r.address)}else if(babelHelpers.typeof(r.address)==="object"){babelHelpers.classPrivateFieldSet(this,Je,new Se(r.address))}else{BX.debug("Wrong typeof props.address")}}}babelHelpers.createClass(e,[{key:"toJson",value:function e(){return Me.convertLocationToJson(this)}},{key:"toAddress",value:function e(){var t=null;if(this.address){var r=JSON.parse(this.address.toJson());r.location=JSON.parse(this.toJson());t=new Se(r)}return t}},{key:"setFieldValue",value:function e(t,r){babelHelpers.classPrivateFieldGet(this,Ve).setFieldValue(t,r)}},{key:"getFieldValue",value:function e(t){return babelHelpers.classPrivateFieldGet(this,Ve).getFieldValue(t)}},{key:"isFieldExists",value:function e(t){return babelHelpers.classPrivateFieldGet(this,Ve).isFieldExists(t)}},{key:"hasExternalRelation",value:function e(){return babelHelpers.classPrivateFieldGet(this,Ne)&&babelHelpers.classPrivateFieldGet(this,Be)}},{key:"id",get:function e(){return babelHelpers.classPrivateFieldGet(this,Oe)},set:function e(t){babelHelpers.classPrivateFieldSet(this,Oe,t)}},{key:"code",get:function e(){return babelHelpers.classPrivateFieldGet(this,Ge)},set:function e(t){babelHelpers.classPrivateFieldSet(this,Ge,t)}},{key:"externalId",get:function e(){return babelHelpers.classPrivateFieldGet(this,Ne)},set:function e(t){babelHelpers.classPrivateFieldSet(this,Ne,t)}},{key:"sourceCode",get:function e(){return babelHelpers.classPrivateFieldGet(this,Be)},set:function e(t){babelHelpers.classPrivateFieldSet(this,Be,t)}},{key:"type",get:function e(){return babelHelpers.classPrivateFieldGet(this,De)},set:function e(t){babelHelpers.classPrivateFieldSet(this,De,t)}},{key:"name",get:function e(){return babelHelpers.classPrivateFieldGet(this,We)},set:function e(t){babelHelpers.classPrivateFieldSet(this,We,t)}},{key:"languageId",get:function e(){return babelHelpers.classPrivateFieldGet(this,Ye)},set:function e(t){babelHelpers.classPrivateFieldSet(this,Ye,t)}},{key:"latitude",get:function e(){return babelHelpers.classPrivateFieldGet(this,je)},set:function e(t){babelHelpers.classPrivateFieldSet(this,je,t)}},{key:"longitude",get:function e(){return babelHelpers.classPrivateFieldGet(this,Ue)},set:function e(t){babelHelpers.classPrivateFieldSet(this,Ue,t)}},{key:"address",set:function e(t){babelHelpers.classPrivateFieldSet(this,Je,t)},get:function e(){return babelHelpers.classPrivateFieldGet(this,Je)}},{key:"fieldCollection",get:function e(){return babelHelpers.classPrivateFieldGet(this,Ve)}}]);return e}();var ze=new WeakMap;var qe=function(){function e(t){babelHelpers.classCallCheck(this,e);ze.set(this,{writable:true,value:""});if(!t.path){throw new Error("props.path must not be empty!")}babelHelpers.classPrivateFieldSet(this,ze,t.path)}babelHelpers.createClass(e,[{key:"run",value:function e(t,r){if(!t){throw new Error("action can not be empty!")}return BX.ajax.runAction("".concat(babelHelpers.classPrivateFieldGet(this,ze),".").concat(t),{data:r})}}]);return e}();function $e(e,t){var r;if(typeof Symbol==="undefined"||e[Symbol.iterator]==null){if(Array.isArray(e)||(r=Ke(e))||t&&e&&typeof e.length==="number"){if(r)e=r;var i=0;var a=function e(){};return{s:a,n:function t(){if(i>=e.length)return{done:true};return{done:false,value:e[i++]}},e:function e(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n=true,l=false,s;return{s:function t(){r=e[Symbol.iterator]()},n:function e(){var t=r.next();n=t.done;return t},e:function e(t){l=true;s=t},f:function e(){try{if(!n&&r.return!=null)r.return()}finally{if(l)throw s}}}}function Ke(e,t){if(!e)return;if(typeof e==="string")return Ze(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor)r=e.constructor.name;if(r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ze(e,t)}function Ze(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,i=new Array(t);r<t;r++){i[r]=e[r]}return i}var Qe=new WeakMap;var et=function(){function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,e);Qe.set(this,{writable:true,value:null});this._path=t.path;if(t.actionRunner&&t.actionRunner instanceof qe){babelHelpers.classPrivateFieldSet(this,Qe,t.actionRunner)}else{babelHelpers.classPrivateFieldSet(this,Qe,new qe({path:this._path}))}}babelHelpers.createClass(e,[{key:"processResponse",value:function e(t){if(t.status!=="success"){BX.debug("Request was not successful");var r="";if(Array.isArray(t.errors)&&t.errors.length>0){var i=$e(t.errors),a;try{for(i.s();!(a=i.n()).done;){var n=a.value;if(typeof n.message==="string"&&n.message!==""){r+="".concat(n,"\n")}}}catch(e){i.e(e)}finally{i.f()}}throw new Error(r)}return t.data?t.data:null}},{key:"path",get:function e(){return this._path}},{key:"actionRunner",get:function e(){return babelHelpers.classPrivateFieldGet(this,Qe)}}]);return e}();function tt(e,t,r){if(!t.has(e)){throw new TypeError("attempted to get private field on non-instance")}return r}var rt=new WeakSet;var it=new WeakSet;var at=function(e){babelHelpers.inherits(t,e);function t(){var e;var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,t);r.path=r.path||"location.api.location";e=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,r));it.add(babelHelpers.assertThisInitialized(e));rt.add(babelHelpers.assertThisInitialized(e));return e}babelHelpers.createClass(t,[{key:"findParents",value:function e(t){if(!(t instanceof Xe)){throw new TypeError("location must be type of Location")}return this.actionRunner.run("findParents",{location:Le.convertLocationToObject(t)}).then(this.processResponse.bind(this)).then(tt(this,rt,nt).bind(this))}},{key:"findByExternalId",value:function e(t,r,i){if(!t||!r||!i){throw new Error("externalId and sourceCode and languageId must be defined")}return this.actionRunner.run("findByExternalId",{externalId:t,sourceCode:r,languageId:i}).then(this.processResponse.bind(this)).then(tt(this,it,lt).bind(this))}},{key:"findById",value:function e(t,r){if(!t||!r){throw new Error("locationId and languageId must be defined")}return this.actionRunner.run("findById",{id:t,languageId:r}).then(this.processResponse.bind(this)).then(tt(this,it,lt).bind(this))}}]);return t}(et);var nt=function e(t){var r=this;if(!Array.isArray(t)){throw new Error("Can't convert location collection data")}var i=[];t.forEach((function(e){i.push(tt(r,it,lt).call(r,e))}));return i};var lt=function e(t){if(!t){return null}if(babelHelpers.typeof(t)!=="object"){throw new Error("Can't convert location data")}return Me.convertJsonToLocation(t)};var st=function(e){babelHelpers.inherits(t,e);function t(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,t);e.path="location.api.address";return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e))}babelHelpers.createClass(t,[{key:"findById",value:function e(t){var r=this;if(t<=0){throw new Error("addressId must be more than zero")}return this.actionRunner.run("findById",{addressId:t}).then(this.processResponse).then((function(e){var t=null;if(e){t=r.convertJsonToAddress(e)}return t}))}},{key:"save",value:function e(t){var r=this;if(!t){throw new Error("address must be defined")}return this.actionRunner.run("save",{address:t}).then(this.processResponse).then((function(e){var t=null;if(babelHelpers.typeof(e)==="object"){t=r.convertJsonToAddress(e)}return t}))}},{key:"convertJsonToAddress",value:function e(t){return new r.Address(t)}}]);return t}(et);var ot=function(e){babelHelpers.inherits(r,e);function r(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,r);e.path="location.api.format";return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(r).call(this,e))}babelHelpers.createClass(r,[{key:"findAll",value:function e(r){var i=this;if(!t.Type.isString(r)){throw new TypeError("languageId must be type of string")}return this.actionRunner.run("findAll",{languageId:r}).then(this.processResponse).then((function(e){return i.convertFormatCollection(e)}))}},{key:"findByCode",value:function e(r,i){if(!t.Type.isString(r)){throw new TypeError("formatCode must be type of string")}if(!t.Type.isString(i)){throw new TypeError("languageId must be type of string")}return this.actionRunner.run("findByCode",{formatCode:r,languageId:i}).then(this.processResponse).then(this.convertFormatData)}},{key:"findDefault",value:function e(r){if(!t.Type.isString(r)){throw new TypeError("languageId must be type of string")}return this.actionRunner.run("findDefault",{languageId:r}).then(this.processResponse).then(this.convertFormatData)}},{key:"convertFormatCollection",value:function e(r){var i=this;if(!t.Type.isArray(r)){throw new TypeError("Can't convert format collection data")}var a=[];r.forEach((function(e){a.push(i.convertFormatData(e))}));return a}},{key:"convertFormatData",value:function e(r){if(!t.Type.isObject(r)){throw new TypeError("Can't convert format data")}return new L(r)}}]);return r}(et);var ut=function(e){babelHelpers.inherits(t,e);function t(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,t);e.path="location.api.source";return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e))}babelHelpers.createClass(t,[{key:"getProps",value:function e(){return this.actionRunner.run("getProps",{}).then(this.processResponse)}}]);return t}(et);var ct=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,[{key:"autocomplete",value:function e(t,r){throw new Error("Method autocomplete() Must be implemented")}}]);return e}();var pt=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,[{key:"requestPhotos",value:function e(t){throw new Error("Must be implemented")}}]);return e}();var ft=function(e){babelHelpers.inherits(t,e);function t(){var e;babelHelpers.classCallCheck(this,t);e=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this));e.setEventNamespace("BX.Location.Core.MapBase");return e}babelHelpers.createClass(t,[{key:"render",value:function e(t){throw new Error("Must be implemented")}},{key:"onLocationChangedEventSubscribe",value:function e(t){throw new Error("Must be implemented")}},{key:"onMapShow",value:function e(){}},{key:"destroy",value:function e(){}},{key:"location",set:function e(t){throw new Error("Must be implemented")}},{key:"mode",set:function e(t){throw new Error("Must be implemented")}},{key:"zoom",set:function e(t){throw new Error("Must be implemented")}}]);return t}(i.EventEmitter);var dt=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,[{key:"sourceCode",get:function e(){throw new Error("Must be implemented")}},{key:"map",get:function e(){throw new Error("Must be implemented")}},{key:"autocompleteService",get:function e(){throw new Error("Must be implemented")}},{key:"photoService",get:function e(){throw new Error("Must be implemented")}},{key:"geocodingService",get:function e(){throw new Error("Must be implemented")}}]);return e}();var bt=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,[{key:"geocode",value:function e(t){if(!t){return Promise.resolve([])}return this.geocodeConcrete(t)}},{key:"geocodeConcrete",value:function e(t){throw new Error("Method geocodeConcrete() must be implemented")}}]);return e}();var vt=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"isValid",value:function t(r){return r===e.edit||r===e.view}},{key:"edit",get:function e(){return"edit"}},{key:"view",get:function e(){return"view"}}]);return e}();var ht=function e(){babelHelpers.classCallCheck(this,e)};babelHelpers.defineProperty(ht,"POSTAL_CODE",50);babelHelpers.defineProperty(ht,"ISO_3166_1_ALPHA_2",1e3);var yt=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(babelHelpers.wrapNativeSuper(Error));var gt=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(babelHelpers.wrapNativeSuper(Error));function Et(e,t,r,i){if(e!==t){throw new TypeError("Private static access of wrong provenance")}if(r.set){r.set.call(e,i)}else{if(!r.writable){throw new TypeError("attempted to set read only private field")}r.value=i}return i}function Ht(e,t,r){if(e!==t){throw new TypeError("Private static access of wrong provenance")}if(r.get){return r.get.call(e)}return r.value}var Pt=function(e){babelHelpers.inherits(t,e);babelHelpers.createClass(t,null,[{key:"getInstance",value:function e(){if(Ht(t,t,Tt)===null){Et(t,t,Tt,new t)}return Ht(t,t,Tt)}}]);function t(){var e;babelHelpers.classCallCheck(this,t);e=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this));e.setEventNamespace("BX.Location.Core.ErrorPublisher");return e}babelHelpers.createClass(t,[{key:"notify",value:function e(r){this.emit(Ht(t,t,kt),{errors:r})}},{key:"subscribe",value:function e(r){babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"subscribe",this).call(this,Ht(t,t,kt),r)}}]);return t}(i.EventEmitter);var Tt={writable:true,value:null};var kt={writable:true,value:"onError"};function wt(e,t,r,i){if(e!==t){throw new TypeError("Private static access of wrong provenance")}if(r.set){r.set.call(e,i)}else{if(!r.writable){throw new TypeError("attempted to set read only private field")}r.value=i}return i}function Ct(e,t,r){if(e!==t){throw new TypeError("Private static access of wrong provenance")}if(r.get){return r.get.call(e)}return r.value}var mt=new WeakMap;var Ft=function(){function e(){babelHelpers.classCallCheck(this,e);mt.set(this,{writable:true,value:"bitrixLocationLastAddress"})}babelHelpers.createClass(e,[{key:"lastAddress",set:function e(t){if(t){BX.localStorage.set(babelHelpers.classPrivateFieldGet(this,mt),{json:t.toJson()},86400*30)}},get:function e(){var t=BX.localStorage.get(babelHelpers.classPrivateFieldGet(this,mt));if(t&&t["json"]){try{return ve.convertJsonToAddress(JSON.parse(t["json"]))}catch(e){}}return null}}],[{key:"getInstance",value:function t(){if(Ct(e,e,St)===null){wt(e,e,St,new e)}return Ct(e,e,St)}}]);return e}();var St={writable:true,value:null};var At=new WeakMap;var _t=new WeakMap;var It=function(){function e(t,r){babelHelpers.classCallCheck(this,e);At.set(this,{writable:true,value:void 0});_t.set(this,{writable:true,value:void 0});babelHelpers.classPrivateFieldSet(this,At,t);babelHelpers.classPrivateFieldSet(this,_t,r)}babelHelpers.createClass(e,[{key:"toArray",value:function e(){return[this.latitude,this.longitude]}},{key:"latitude",get:function e(){return babelHelpers.classPrivateFieldGet(this,At)}},{key:"longitude",get:function e(){return babelHelpers.classPrivateFieldGet(this,_t)}}],[{key:"fromJson",value:function t(r){return new e(r.latitude,r.longitude)}}]);return e}();var Rt=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"getDistanceFromLatLonInKm",value:function t(r,i,a,n){var l=6371;var s=e.deg2rad(a-r);var o=e.deg2rad(n-i);var u=Math.sin(s/2)*Math.sin(s/2)+Math.cos(e.deg2rad(r))*Math.cos(e.deg2rad(a))*Math.sin(o/2)*Math.sin(o/2);var c=2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u));return l*c}},{key:"deg2rad",value:function e(t){return t*(Math.PI/180)}}]);return e}();e.Location=Xe;e.Address=Se;e.Format=L;e.AddressType=S;e.LocationType=F;e.LocationFieldType=ht;e.FormatTemplateType=R;e.FormatTemplate=A;e.FormatTemplateCollection=I;e.LocationRepository=at;e.AddressRepository=st;e.FormatRepository=ot;e.SourceRepository=ut;e.AddressStringConverter=de;e.AutocompleteServiceBase=ct;e.PhotoServiceBase=pt;e.BaseSource=dt;e.MapBase=ft;e.GeocodingServiceBase=bt;e.LocationJsonConverter=Me;e.ControlMode=vt;e.SourceCreationError=yt;e.MethodNotImplemented=gt;e.ErrorPublisher=Pt;e.Storage=Ft;e.Point=It;e.DistanceCalculator=Rt})(this.BX.Location.Core=this.BX.Location.Core||{},BX,BX.Location.Core,BX.Event);
//# sourceMappingURL=core.bundle.map.js